package name.marz.to.go.ahg.mufgbk.executer;

import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import name.marz.to.go.ahg.common.util.HttpUtil;
import name.marz.to.go.ahg.core.AutoGetterHttpClient;
import name.marz.to.go.ahg.core.Parameters;
import name.marz.to.go.ahg.core.executer.AbstractPostFileDownloader;
import name.marz.to.go.ahg.mufgbk.MUFGbkUtil;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.jsoup.nodes.Document;

public class MUFGbkCSVDownloader extends AbstractPostFileDownloader {
	private final Document doc;

	public MUFGbkCSVDownloader(URI uri, AutoGetterHttpClient client, File file, Document doc) {
		super(uri, client, file);
		this.doc = doc;
	}

	@Override
	protected List<NameValuePair> getRequestParameters() {
		Parameters p = HttpUtil.getParametersFromFormTag(doc, MUFGbkUtil.COMMON_FORM_NAME);
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("_TRANID", "CP107_001"));
		params.add(new BasicNameValuePair("_TARGET", ""));
		params.add(new BasicNameValuePair("_FRAMID", ""));
		params.add(new BasicNameValuePair("_TARGETWINID", ""));
		params.add(p.getNameValuePair("_LUID"));
		params.add(p.getNameValuePair("_SENDTS"));
		params.add(p.getNameValuePair("_PAGEID"));
		params.add(p.getNameValuePair("_WINID"));
		params.add(p.getNameValuePair("_SUBINDEX"));
		params.add(new BasicNameValuePair("SHOUKAIKIKAN_RADIO", "2"));
		params.add(p.getNameValuePair("SHIBORIKOMI"));
		params.add(p.getNameValuePair("SHOUKAIKIKAN_FROM_D"));
		params.add(p.getNameValuePair("SHOUKAIKIKAN_FROM_M"));
		params.add(p.getNameValuePair("SHOUKAIKIKAN_FROM_Y"));
		params.add(p.getNameValuePair("SHOUKAIKIKAN_TO_D"));
		params.add(p.getNameValuePair("SHOUKAIKIKAN_TO_M"));
		params.add(p.getNameValuePair("SHOUKAIKIKAN_TO_Y"));
		
		return params;
	}
}